package com.tcxhb.job.core.service.job.impl;

import com.tcxhb.job.dao.dataobject.JobInstanceDO;
import com.tcxhb.job.dao.dataobject.query.JobInstanceQuery;
import com.tcxhb.job.dao.repository.JobInstanceRepository;
import com.tcxhb.job.core.service.job.JobInstanceService;
import com.tcxhb.job.common.model.PageResponse;
import com.tcxhb.job.common.utils.ParamUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * author:auto.generator
 * time: 2023-11-05
 */
@Service
public class JobInstanceServiceImpl implements JobInstanceService {
    @Resource
    private JobInstanceRepository repository;

    @Override
    public Long create(JobInstanceDO instanceDO) {
        ParamUtils.notNull(instanceDO.getTraceId(), "traceId不能为空");
        Long id = repository.create(instanceDO);
        instanceDO.setId(id);
        return id;
    }

    @Override
    public JobInstanceDO queryByTraceId(Long jobId, String traceId) {
        JobInstanceDO exit = repository.queryByTraceId(jobId, traceId);
        return exit;
    }

    @Override
    public boolean deleteById(Long id) {
        ParamUtils.notNull(id, "id不能为空");
        return repository.deleteById(id);
    }

    @Override
    public boolean updateById(JobInstanceDO tcJobInstance) {
        return repository.updateById(tcJobInstance);
    }

    @Override
    public JobInstanceDO queryById(Long id) {
        ParamUtils.notNull(id, "id不能为空");
        return repository.queryById(id);
    }

    @Override
    public PageResponse<JobInstanceDO> page(JobInstanceQuery query) {
        return repository.page(query);
    }

    @Override
    public List<JobInstanceDO> list(JobInstanceQuery query) {
        return repository.list(query);
    }

    @Override
    public List<JobInstanceDO> scan(JobInstanceQuery query) {
        return repository.scan(query);
    }
}
